package com.jeeplus.modules.work.queue.service;

import com.jeeplus.database.datasource.annotation.DS;
import com.jeeplus.modules.work.queue.mapper.RealEstateMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@DS("queuing")
@Service
@RequiredArgsConstructor
@Slf4j
@Transactional
public class RealEstateService {
    private final RealEstateMapper mapper;
    public Map<String,Map<String,Integer>> getQuantity(Map<String,String> map){
        Map<String,Map<String,Integer>> mapMap=new HashMap<>();
        mapMap.put("Total",mapper.getTotal(map));
        mapMap.put("OneWindow",mapper.getOneWindow(map));
        return mapMap;
    };

    public List<Map<String,Object>> getQuanQu(String time){
        List<Map<String, Object>> quanQu = mapper.getQuanQu(time);
        Integer gcjs = mapper.getGCJS(time);
        Integer shsw = mapper.getSHSW(time);
        Map<String, Object> map=null;
        for (int i = 0; i < quanQu.size(); i++) {
            if (quanQu.get(i).get("area").equals("2F-B区社治保障局")){
                int number = (int) quanQu.get(i).get("number") - gcjs;
                quanQu.get(i).put("number",number);
                map=new HashMap<>();
                map.put("area","2F-B区工程建设");
                map.put("number",gcjs);
                quanQu.add(map);
            }else if (quanQu.get(i).get("area").equals("2F-C区人才资源中心")){
                int number = (int)quanQu.get(i).get("number") - shsw;
                quanQu.get(i).put("number",number);
                map=new HashMap<>();
                map.put("area","2F-C区社会事务");
                map.put("number",shsw);
                quanQu.add(map);
            }
        }
        return quanQu;
    }

    public Map<String,Object> getMonthApprais(String startCno,String endCno,String syson,String startTime,String endTime){
        Map<String, Object> monthApprais = mapper.getMonthApprais(startCno, endCno, syson, startTime, endTime);

        return monthApprais;
    }
    public List<Map<String,String>> getMonthAppraisArea(){

        return mapper.getMonthAppraisArea();
    }


}
